home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Applications / MathPad 2.4 / XFuns / XFun kit / util src / entryPPC.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-14  |  1.8 KB  |  49 lines  |  [TEXT/CWIE]

  1. /*
  2.    This file contains a generic initialization entry point for PPC CFuns.
  3.    The prototypes in "callbackg.h" are used but the Code Fragment Manager
  4.    links directly to the MathPadPPC routines. The "callbackg.c" interface
  5.    routines are not needed.
  6.  
  7.    All the real work is done elsewhere by the routines:
  8.    
  9.      initialize()
  10.      doevent(theEvent)
  11.      dopredef()
  12.      dofuncall(retval)
  13.    
  14.    This example uses all 4 possible entry points.
  15.    The InitCFun() and dofuncall() entries are required for all CFuns.
  16.    The dopredef() is used only if your CFun needs to reset something each time
  17.    the doc is reevaluated. If it isn't used just pass a NULL to AddCfun().
  18.    The handler() is used if your CFun needs access to events. If your CFun
  19.    creates a window it must install a valid handler.  If no handler is needed
  20.    then don't call InstallEventHandler().
  21.    
  22.    InitCFun is the code fragment initialization entry point. This name must match the 
  23.    linker's initialization symbol name. The fragment has no main or termination routines.
  24.    
  25.    The call to FSpOpenResFile() is to allow a CFun access to resources from its own file
  26.    during its initialize() routine. If your CFun doesn't need this access there is no
  27.    need to open and close the resource file.
  28. */
  29.  
  30. #include <CodeFragments.h>
  31. #include "callbackg.h"        /* prototypes for callbacks */
  32. #include "CFundef.h"        /* prototypes for routines specific to this CFun */
  33.  
  34. OSErr InitCFun(CFragInitBlockPtr iblk);
  35.  
  36. OSErr InitCFun(CFragInitBlockPtr iblk)
  37. {
  38.    FSSpecPtr fspec;
  39.    int ref;
  40.    
  41.    AddCFun(FUNNAME,FUNPARMS,&dofuncall,&dopredef);
  42.    InstallEventHandler(&doevent);
  43.    fspec = iblk->fragLocator.u.onDisk.fileSpec;    // get this fragment's FSspec
  44.    ref = FSpOpenResFile(fspec,fsCurPerm);
  45.    initialize();
  46.    CloseResFile(ref);
  47.    return noErr;
  48. }
  49.